<template>
  <div class="container">
    <div class="screen" ref="screen">
      <div class="screen-header">
        <ScreenHeader></ScreenHeader>
      </div>
      <div class="screen-content">
        <div class="content-left">
          <div class="item1"></div>
          <div class="item2"></div>
          <div class="item3"></div>
        </div>
        <div class="content-center">
          中
        </div>
        <div class="content-right">
          右
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="js">
import { onMounted, ref } from 'vue'
import ScreenHeader from '@/views/screen/components/header/index.vue'

// 0 获取大屏 DOM 对象
const screen = ref()

// 2
onMounted(() => {
  screen.value.style.transform = `scale(${defScale()}) translate(-50%, -50%)`
})

// 1 定义大屏缩放比例
function defScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}

// 3 监听视口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${defScale()}) translate(-50%, -50%)`
}
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url("./images/screen-bg.png") no-repeat;
  background-size: cover;

  .screen {
    position: fixed; 
    top: 50%;
    left: 50%;
    width: 1920px;
    height: 1080px;
    transform-origin: top left;

    .screen-header {
      width: 100%;
      height: 50px;
    }

    .screen-content {
      display: flex;
      height: calc(1080px - 50px);

      .content-left {
        flex: 1;
        display: flex;
        flex-direction: column;
        
        .item1 {
          flex: 1.5;
          background: #000;
        }

        .item2 {
          flex: 1.2;
          background: #fff;
        }

        .item3 {
          flex: 1.3;
          background: #000;
        }
      }

      .content-center {
        flex: 2;
      }

      .content-right {
        flex: 1;
      }
    }
  }
}
</style>